// atan.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"


BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    return TRUE;
}

#define KIN_PI 3.1415926
#define LREAL double


LREAL FUN_ATAN(LREAL Yparam, LREAL Xparam)
{
	LREAL rtn;
	if (Xparam > 0.0) 
	{
		rtn = atan (Yparam / Xparam);
	}
	else if ((Xparam==0.0) & (Yparam>0.0))
	{
		rtn = KIN_PI;
	}
	else if ((Xparam==0.0) & (Yparam <0.0))
	{
		rtn = -KIN_PI;
	}
	else if ((Xparam<0.0) & (Yparam>0.0))
	{
		rtn = atan(Yparam/Xparam) + KIN_PI;
	}
	else if ((Xparam<0.0) & (Yparam<0.0))
	{
		rtn =atan(Yparam/Xparam) - KIN_PI;
	}
	else if ((Xparam<0.0) & (Yparam==0))
	{
		rtn = KIN_PI;
	}
	else
		rtn = 0.0;

	return rtn;	

}



extern "C" _declspec(dllexport) void *GetFunctionByName(char* szName) 
{ 
	if (_stricmp(szName, "FUN_ATAN") == 0) 
		return (void*)FUN_ATAN;
	else 
		return NULL;
}